var nameMap=[]; 
var companyId=null;



$(function(){
	
  $.ajax({
	type : "POST",
	url : "/Listen/listenModuleRole/selectCount.action",
	async : false,
	success : function(mes){
		$("#SalesToday").html(mes.todaySell);
		$("#Finance").html(mes.finance);
		$("#GrossProceed").html(mes.sell);
		$("#Stock").html(mes.stock);
	}
},'json');  
  
  
 
  $.ajaxSetup({
		async: false
	});
  var url="/Listen/statisticalChart/findCompanyId.action";
  var data=null;
  $.post(url,data,function(mes){
	  companyId=mes;
  },"json");
  $.ajaxSetup({
		async: true
	});
  if(companyId=="1"){
	  $(".echartsOne").html("乐器总前八销量")
	  $(".echartsTwo").html("总销量排名前三乐器的月销量")
	  $(".echartsThree").html("乐器月销售月总额和采购材料月总额")
	  $(".echartsFour").html("乐器总销售金额前五排名")
	  sumSale();
	  yearSale(null);
	  monthsSale(null)
	  sumPriceSale(null);
	  
	  $("#warning").append("<div class='echarts' id='warning' style='width:50%; height:350px;border: 1px solid #D3D3D3;margin: 0 auto;box-shadow: 0 0 10px #C0C0C0'>"+
								"<div class='layui-tab layui-tab-brief' lay-filter='docDemoTabBrief'>"+
								  "<ul class='layui-tab-title'>"+
								    "<li class='layui-this'>材料库存预警</li>"+
								    "<li>乐器库存预警</li>"+
								  "</ul>"+
								  "<div class='layui-tab-content' style='height: 277px;width: 96%;margin:0 auto;padding:0px;border: 1px solid #D3D3D3;box-shadow: 0 0 10px #C0C0C0;'>"+
								    "<div class='layui-tab-item layui-show'><iframe src='pages/warning/materialWarning.html' style='border:0px;width:100%;height:100%;'></iframe></div>"+
								    "<div class='layui-tab-item'><iframe src='pages/warning/musicalWarning.html' style='border:0px;width:100%;height:100%;'></iframe></div>"+
								  "</div>"+
								"</div>"+     
							"</div>")
  }else{
	  $(".echartsOne").html("乐器批发前八销量")
	  $(".echartsTwo").html("批发和零售月销量")
	  $(".echartsThree").html("乐器月批发月总额和乐器零售月总额")
	  $(".echartsFour").html("乐器零售前八销量")
	  wholesaleSumSale();
	  retailSumSale();
	  wholesaleOrRetailNumberSumSale({"attribute":"number"});
	  wholesaleOrRetailPriceSumSale({"attribute":"price"});
	  
	  
	  $("#warning").append("<div class='echarts' id='warning' style='width:50%; height:350px;border: 1px solid #D3D3D3;margin: 0 auto;box-shadow: 0 0 10px #C0C0C0'>"+
				"<div class='layui-tab layui-tab-brief' lay-filter='docDemoTabBrief'>"+
				  "<ul class='layui-tab-title'>"+
				    "<li class='layui-this'>乐器库存预警</li>"+
				  "</ul>"+
				  "<div class='layui-tab-content' style='height: 277px;width: 96%;margin:0 auto;padding:0px;border: 1px solid #D3D3D3;box-shadow: 0 0 10px #C0C0C0;'>"+
				    "<div class='layui-tab-item layui-show'><iframe src='pages/warning/musicalWarning.html' style='border:0px;width:100%;height:100%;'></iframe></div>"+
				  "</div>"+
				"</div>"+     
			"</div>")
  }
  
 
  
  
 })
 
  function wholesaleOrRetailPriceSumSale(data){
	var name=new Array();
	var wholesale=new Array();
	var retail=new Array();
	var url="/Listen/statisticalChart/selectMonthsNumberPriceStatistics.action";
	  $.post(url,data,function(mes){
	  		$.each(mes,function(i,item){
	  			name.push(item.name)
	  			if(i==0){
	  				var j={};
		  			var arr=new Array();
		  			var arr2=new Array();
		  			arr=item.value.split(",");
		  			for (var i = 0; i < arr.length-1; i++) {
		  				wholesale.push(parseInt(arr[i]))
					}
		  			 
	  			}else{
	  				var j={};
		  			var arr=new Array();
		  			var arr2=new Array();
		  			arr=item.value.split(",");
		  			for (var i = 0; i < arr.length-1; i++) {
		  				retail.push(parseFloat(arr[i]))
					}
		  		 
	  			}
	  		}) 
	  		
	  	
	  		 var yearsChart = echarts.init(document.getElementById('years'));
	  		 option = {
	  				    backgroundColor: "#FFFFFF",
	  				    tooltip: {},
	  				    grid: {
	  				        top: '8%',
	  				        left: '1%',
	  				        right: '1%',
	  				        bottom: '8%',
	  				        containLabel: true,
	  				    },
	  				    legend: {
	  				        itemGap: 50,
	  				        data: name,
	  				        textStyle: {
	  				            color: '#2F4F4F',
	  				            borderColor: '#fff'
	  				        },
	  				    },
	  				    xAxis: [{
	  				        type: 'category',
	  				        boundaryGap: true,
	  				        axisLine: { //坐标轴轴线相关设置。数学上的x轴
	  				            show: true,
	  				            lineStyle: {
	  				                color: '#f9f9f9'
	  				            },
	  				        },
	  				        axisLabel: { //坐标轴刻度标签的相关设置
	  				            textStyle: {
	  				                color: '#2F4F4F',
	  				                margin: 15,
	  				            },
	  				        },
	  				        axisTick: {
	  				            show: false,
	  				        },
	  				        data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月',],
	  				    }],
	  				    yAxis: [{
	  				        type: 'value',
	  				        min: 0,
	  				        // max: 140,
	  				        splitNumber: 7,
	  				        splitLine: {
	  				            show: true,
	  				            lineStyle: {
	  				                color: '#C0C0C0'
	  				            }
	  				        },
	  				        axisLine: {
	  				            show: false,
	  				        },
	  				        axisLabel: {
	  				            margin: 20,
	  				            textStyle: {
	  				                color: '#2F4F4F',

	  				            },
	  				        },
	  				        axisTick: {
	  				            show: false,
	  				        },
	  				    }],
	  				    series: [{
	  				        name: '批发乐器月季总额',
	  				        type: 'line',
	  				        // smooth: true, //是否平滑曲线显示
	  				        // 			symbol:'circle',  // 默认是空心圆（中间是白色的），改成实心圆
	  				        showAllSymbol: true,
	  				        symbol: 'emptyCircle',
	  				        symbolSize: 6,
	  				        lineStyle: {
	  				            normal: {
	  				                color: "#28ffb3", // 线条颜色
	  				            },
	  				            borderColor: '#f0f'
	  				        },
	  				        label: {
	  				            show: true,
	  				            position: 'top',
	  				            textStyle: {
	  				                color: '#2F4F4F',
	  				            }
	  				        },
	  				        itemStyle: {
	  				            normal: {
	  				                color: "#28ffb3",

	  				            }
	  				        },
	  				        tooltip: {
	  				            show: false
	  				        },
	  				        areaStyle: { //区域填充样式
	  				            normal: {
	  				                //线性渐变，前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’，则该四个值是绝对像素位置。
	  				                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
	  				                        offset: 0,
	  				                        color: 'rgba(0,154,120,1)'
	  				                    },
	  				                    {
	  				                        offset: 1,
	  				                        color: 'rgba(0,0,0, 0)'
	  				                    }
	  				                ], false),
	  				                shadowColor: 'rgba(53,142,215, 0.9)', //阴影颜色
	  				                shadowBlur: 20 //shadowBlur设图形阴影的模糊大小。配合shadowColor,shadowOffsetX/Y, 设置图形的阴影效果。
	  				            }
	  				        },
	  				        data: wholesale
	  				    }, {
	  				        name: '零售乐器月季总额',
	  				        type: 'bar',
	  				        barWidth: 20,
	  				        tooltip: {
	  				            show: false
	  				        },
	  				         label: {
	  				            show: true,
	  				            position: 'top',
	  				            textStyle: {
	  				                color: '#2F4F4F',
	  				            }
	  				        },
	  				        itemStyle: {
	  				            normal: {
	  				                // barBorderRadius: 5,
	  				                // color: new echarts.graphic.LinearGradient(
	  				                //     0, 0, 0, 1,
	  				                //     [{
	  				                //             offset: 0,
	  				                //             color: '#14c8d4'
	  				                //         },
	  				                //         {
	  				                //             offset: 1,
	  				                //             color: '#43eec6'
	  				                //         }
	  				                //     ]
	  				                // )
	  				                color: function(params) {
	  				                    var colorList = ['#0ec1ff', '#10cdff', '#12daff', '#15ebff', '#17f8ff', '#1cfffb', '#1dfff1'];
	  				                    return colorList[params.dataIndex];
	  				                }
	  				            }
	  				        },
	  				        data: retail
	  				    }]
	  				};
	  	 
	  		yearsChart.setOption(option);
	  		
	  		
	  },"json");
}
 
 
  function wholesaleOrRetailNumberSumSale(data){
	var name=new Array();
	var wholesale=new Array();
	var retail=new Array();
	var sumNumber=new Array();
	var url="/Listen/statisticalChart/selectMonthsNumberPriceStatistics.action";
	  $.post(url,data,function(mes){
	  		$.each(mes,function(i,item){
	  			name.push(item.name)
	  			if(i==0){
	  				var j={};
		  			var arr=new Array();
		  			var arr2=new Array();
		  			arr=item.value.split(",");
		  			for (var i = 0; i < arr.length-1; i++) {
		  				wholesale.push(parseInt(arr[i]))
					}
		  			 
	  			}else{
	  				var j={};
		  			var arr=new Array();
		  			var arr2=new Array();
		  			arr=item.value.split(",");
		  			for (var i = 0; i < arr.length-1; i++) {
		  				retail.push(parseFloat(arr[i]))
					}
		  		 
	  			}
	  		}) 
	  		
	  		for (var i = 0; i < 12; i++) {
	  			sumNumber.push(parseInt(wholesale[i])+parseInt(retail[i]))
			}
	  		 
	  		var mainChart = echarts.init(document.getElementById('Crash&Dash'));
	  		console.info(name)
	  		var xData = function() {
	  		    var data = [];
	  		    for (var i = 1; i < 13; i++) {
	  		        data.push(i + "月份");
	  		    }
	  		    return data;
	  		}();

	  		option = {
	  		    backgroundColor: "#FFFFFF",
	  		    
	  		    "tooltip": {
	  		        "trigger": "axis",
	  		        "axisPointer": {
	  		            "type": "shadow",
	  		            textStyle: {
	  		                color: "#fff"
	  		            }

	  		        },
	  		    },
	  		    "grid": {
	  		        "borderWidth": 0,
	  		        "top": 110,
	  		        "bottom": 95,
	  		        textStyle: {
	  		            color: "#fff"
	  		        }
	  		    },
	  		    "legend": {
	  		        x: '4%',
	  		        top: '11%',
	  		        textStyle: {
	  		            color: '#90979c',
	  		        },
	  		        "data": name
	  		    },
	  		     

	  		    "calculable": true,
	  		    "xAxis": [{
	  		        "type": "category",
	  		        "axisLine": {
	  		            lineStyle: {
	  		                color: '#90979c'
	  		            }
	  		        },
	  		        "splitLine": {
	  		            "show": false
	  		        },
	  		        "axisTick": {
	  		            "show": false
	  		        },
	  		        "splitArea": {
	  		            "show": false
	  		        },
	  		        "axisLabel": {
	  		            "interval": 0,

	  		        },
	  		        "data": xData,
	  		    }],
	  		    "yAxis": [{
	  		        "type": "value",
	  		        "splitLine": {
	  		            "show": false
	  		        },
	  		        "axisLine": {
	  		            lineStyle: {
	  		                color: '#90979c'
	  		            }
	  		        },
	  		        "axisTick": {
	  		            "show": false
	  		        },
	  		        "axisLabel": {
	  		            "interval": 0,

	  		        },
	  		        "splitArea": {
	  		            "show": false
	  		        },

	  		    }],
	  		    
	  		    "series": [{
	  		            "name": "批发乐器月季数量",
	  		            "type": "bar",
	  		            "stack": "总量",
	  		            "barMaxWidth": 35,
	  		            "barGap": "10%",
	  		            "itemStyle": {
	  		                "normal": {
	  		                    "color": "rgba(255,144,128,1)",
	  		                    "label": {
	  		                        "show": true,
	  		                        "textStyle": {
	  		                            "color": "#fff"
	  		                        },
	  		                        "position": "insideTop",
	  		                        formatter: function(p) {
	  		                            return p.value > 0 ? (p.value) : '';
	  		                        }
	  		                    }
	  		                }
	  		            },
	  		            "data":wholesale,
	  		        },

	  		        {
	  		            "name": "零售乐器月季数量",
	  		            "type": "bar",
	  		            "stack": "总量",
	  		            "itemStyle": {
	  		                "normal": {
	  		                    "color": "rgba(0,191,183,1)",
	  		                    "barBorderRadius": 0,
	  		                    "label": {
	  		                        "show": true,
	  		                        "position": "top",
	  		                        formatter: function(p) {
	  		                            return p.value > 0 ? (p.value) : '';
	  		                        }
	  		                    }
	  		                }
	  		            },
	  		            "data":retail
	  		        }, {
	  		            "name": "总数",
	  		            "type": "line",
	  		            "stack": "总量",
	  		            symbolSize:10,
	  		            symbol:'circle',
	  		            "itemStyle": {
	  		                "normal": {
	  		                    "color": "rgba(252,230,48,1)",
	  		                    "barBorderRadius": 0,
	  		                    "label": {
	  		                        "show": true,
	  		                        "position": "top",
	  		                        formatter: function(p) {
	  		                            return p.value > 0 ? (p.value) : '';
	  		                        }
	  		                    }
	  		                }
	  		            },
	  		            "data": sumNumber
	  		        },
	  		    ]
	  		}

	  		 mainChart.setOption(option);
	  },"json");
	  
}
 
function retailSumSale(){
	var datas=[];
	var url="/Listen/statisticalChart/retailStatistics.action";
	  var data=null;
	  $.post(url,data,function(mes){
	  	$.each(mes,function(i,item){
	  		var j={}
	  		j.value=item.value;
	  		j.name=item.name;
	  		datas.push(j)
	  	})
	  	var productChart = echarts.init(document.getElementById('product'));
	  	option = {
	  		    
	  		    tooltip : {
	  		        trigger: 'item',
	  		        formatter: "{a} <br/>{b} : {c} ({d}%)"
	  		    },
	  		    legend: {
	  		        x : 'center',
	  		        y : 'bottom',
	  		        data:datas
	  		    },
	  		    toolbox: {
	  		        show : true,
	  		        feature : {
	  		            mark : {show: true},
	  		            dataView : {show: true, readOnly: false},
	  		            magicType : {
	  		                show: true,
	  		                type: ['pie', 'funnel']
	  		            },
	  		            restore : {show: true},
	  		            saveAsImage : {show: true}
	  		        }
	  		    },
	  		    calculable : true,
	  		    series : [
	  		        {
	  		            name:'半径模式',
	  		            type:'pie',
	  		            radius : [20, 110],
	  		            center : ['25%', '50%'],
	  		            roseType : 'radius',
	  		            label: {
	  		                normal: {
	  		                    show: false
	  		                },
	  		                emphasis: {
	  		                    show: true
	  		                }
	  		            },
	  		            lableLine: {
	  		                normal: {
	  		                    show: false
	  		                },
	  		                emphasis: {
	  		                    show: true
	  		                }
	  		            },
	  		            data: datas
	  		        },
	  		        {
	  		            name:'面积模式',
	  		            type:'pie',
	  		            radius : [30, 110],
	  		            center : ['75%', '50%'],
	  		            roseType : 'area',
	  		            data:datas
	  		        }
	  		    ]
	  		};
	    // 使用刚指定的配置项和数据显示图表。
	  	productChart.setOption(option);
	  },"json"); 
};  
 
 
function wholesaleSumSale(){
	var datas=[];
	var url="/Listen/statisticalChart/wholesaleStatistics.action";
	  var data=null;
	  $.post(url,data,function(mes){
	  	$.each(mes,function(i,item){
	  		var j={}
	  		j.value=item.value;
	  		j.name=item.name;
	  		datas.push(j)
	  	})
	  	 var mainChart = echarts.init(document.getElementById('type'));

	  	option = {
	  		    
	  		    tooltip : {
	  		        trigger: 'item',
	  		        formatter: "{a} <br/>{b} : {c} ({d}%)"
	  		    },
	  		    legend: {
	  		        x : 'center',
	  		        y : 'bottom',
	  		        data:datas
	  		    },
	  		    toolbox: {
	  		        show : true,
	  		        feature : {
	  		            mark : {show: true},
	  		            dataView : {show: true, readOnly: false},
	  		            magicType : {
	  		                show: true,
	  		                type: ['pie', 'funnel']
	  		            },
	  		            restore : {show: true},
	  		            saveAsImage : {show: true}
	  		        }
	  		    },
	  		    calculable : true,
	  		    series : [
	  		        {
	  		            name:'半径模式',
	  		            type:'pie',
	  		            radius : [20, 110],
	  		            center : ['25%', '50%'],
	  		            roseType : 'radius',
	  		            label: {
	  		                normal: {
	  		                    show: false
	  		                },
	  		                emphasis: {
	  		                    show: true
	  		                }
	  		            },
	  		            lableLine: {
	  		                normal: {
	  		                    show: false
	  		                },
	  		                emphasis: {
	  		                    show: true
	  		                }
	  		            },
	  		            data: datas
	  		        },
	  		        {
	  		            name:'面积模式',
	  		            type:'pie',
	  		            radius : [30, 110],
	  		            center : ['75%', '50%'],
	  		            roseType : 'area',
	  		            data:datas
	  		        }
	  		    ]
	  		};

	    // 使用刚指定的配置项和数据显示图表。
	    mainChart.setOption(option);
	  },"json"); 
}; 
 
function sumPriceSale(data){
	var datas=[];
	var url="/Listen/statisticalChart/selectSumPriceStatistics.action";
	  $.post(url,data,function(mes){
	  		$.each(mes,function(i,item){
	  			var j={}
		  		j.value=item.price;
		  		j.name=item.name;
		  		datas.push(j)
	  		});
	  		 
	  		var productChart = echarts.init(document.getElementById('product'));
	  		option = {
	  			    backgroundColor: '#FFFFFF',

	  			    
	  			    tooltip : {
	  			        trigger: 'item',
	  			        formatter: "{a} <br/>{b} : {c} ({d}%)"
	  			    },

	  			    visualMap: {
	  			        show: false,
	  			        min: 80,
	  			        max: 100000,
	  			        inRange: {
	  			            colorLightness: [0, 1]
	  			        }
	  			    },
	  			    series : [
	  			        {
	  			            name:'访问来源',
	  			            type:'pie',
	  			            radius : '70%',
	  			            center: ['50%', '50%'],
	  			            data:datas.sort(function (a, b) { return a.value - b.value; }),
	  			            roseType: 'radius',
	  			            label: {
	  			                normal: {
	  			                    textStyle: {
	  			                        color: '#FFA500'
	  			                    }
	  			                }
	  			            },
	  			            labelLine: {
	  			                normal: {
	  			                    lineStyle: {
	  			                        color: '#A9A9A9'
	  			                    },
	  			                    smooth: 0.2,
	  			                    length: 40,
	  			                    length2: 10
	  			                }
	  			            },
	  			            itemStyle: {
	  			                normal: {
	  			                    color: '#c23531',
	  			                    shadowBlur: 200,
	  			                    shadowColor: '#FFFFFF'
	  			                }
	  			            },

	  			            animationType: 'scale',
	  			            animationEasing: 'elasticOut',
	  			            animationDelay: function (idx) {
	  			                return Math.random() * 200;
	  			            }
	  			        }
	  			    ]
	  			};
	  		productChart.setOption(option);
	  },"json");
	
	
	
} 

 function monthsSale(data){
	var name=new Array();
	var material=new Array();
	var musical=new Array();
	var url="/Listen/statisticalChart/selectMonthsPriceStatistics.action";
	  $.post(url,data,function(mes){
	  		$.each(mes,function(i,item){
	  			name.push(item.name)
	  			if(i==0){
	  				var j={};
		  			var arr=new Array();
		  			var arr2=new Array();
		  			arr=item.value.split(",");
		  			for (var i = 0; i < arr.length-1; i++) {
		  				musical.push(parseInt(arr[i]))
					}
		  			 
	  			}else{
	  				var j={};
		  			var arr=new Array();
		  			var arr2=new Array();
		  			arr=item.value.split(",");
		  			for (var i = 0; i < arr.length-1; i++) {
		  				material.push(parseInt(arr[i]))
					}
		  		 
	  			}
	  		}) 
	  		
	  	
	  		 var yearsChart = echarts.init(document.getElementById('years'));
	  		 option = {
	  				    backgroundColor: "#FFFFFF",
	  				    tooltip: {},
	  				    grid: {
	  				        top: '8%',
	  				        left: '1%',
	  				        right: '1%',
	  				        bottom: '8%',
	  				        containLabel: true,
	  				    },
	  				    legend: {
	  				        itemGap: 50,
	  				        data: name,
	  				        textStyle: {
	  				            color: '#2F4F4F',
	  				            borderColor: '#fff'
	  				        },
	  				    },
	  				    xAxis: [{
	  				        type: 'category',
	  				        boundaryGap: true,
	  				        axisLine: { //坐标轴轴线相关设置。数学上的x轴
	  				            show: true,
	  				            lineStyle: {
	  				                color: '#f9f9f9'
	  				            },
	  				        },
	  				        axisLabel: { //坐标轴刻度标签的相关设置
	  				            textStyle: {
	  				                color: '#2F4F4F',
	  				                margin: 15,
	  				            },
	  				        },
	  				        axisTick: {
	  				            show: false,
	  				        },
	  				        data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月',],
	  				    }],
	  				    yAxis: [{
	  				        type: 'value',
	  				        min: 0,
	  				        // max: 140,
	  				        splitNumber: 7,
	  				        splitLine: {
	  				            show: true,
	  				            lineStyle: {
	  				                color: '#C0C0C0'
	  				            }
	  				        },
	  				        axisLine: {
	  				            show: false,
	  				        },
	  				        axisLabel: {
	  				            margin: 20,
	  				            textStyle: {
	  				                color: '#2F4F4F',

	  				            },
	  				        },
	  				        axisTick: {
	  				            show: false,
	  				        },
	  				    }],
	  				    series: [{
	  				        name: '销售乐器月季总额',
	  				        type: 'line',
	  				        // smooth: true, //是否平滑曲线显示
	  				        // 			symbol:'circle',  // 默认是空心圆（中间是白色的），改成实心圆
	  				        showAllSymbol: true,
	  				        symbol: 'emptyCircle',
	  				        symbolSize: 6,
	  				        lineStyle: {
	  				            normal: {
	  				                color: "#28ffb3", // 线条颜色
	  				            },
	  				            borderColor: '#f0f'
	  				        },
	  				        label: {
	  				            show: true,
	  				            position: 'top',
	  				            textStyle: {
	  				                color: '#2F4F4F',
	  				            }
	  				        },
	  				        itemStyle: {
	  				            normal: {
	  				                color: "#28ffb3",

	  				            }
	  				        },
	  				        tooltip: {
	  				            show: false
	  				        },
	  				        areaStyle: { //区域填充样式
	  				            normal: {
	  				                //线性渐变，前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’，则该四个值是绝对像素位置。
	  				                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
	  				                        offset: 0,
	  				                        color: 'rgba(0,154,120,1)'
	  				                    },
	  				                    {
	  				                        offset: 1,
	  				                        color: 'rgba(0,0,0, 0)'
	  				                    }
	  				                ], false),
	  				                shadowColor: 'rgba(53,142,215, 0.9)', //阴影颜色
	  				                shadowBlur: 20 //shadowBlur设图形阴影的模糊大小。配合shadowColor,shadowOffsetX/Y, 设置图形的阴影效果。
	  				            }
	  				        },
	  				        data: material
	  				    }, {
	  				        name: '采购材料月季总额',
	  				        type: 'bar',
	  				        barWidth: 20,
	  				        tooltip: {
	  				            show: false
	  				        },
	  				         label: {
	  				            show: true,
	  				            position: 'top',
	  				            textStyle: {
	  				                color: '#2F4F4F',
	  				            }
	  				        },
	  				        itemStyle: {
	  				            normal: {
	  				                // barBorderRadius: 5,
	  				                // color: new echarts.graphic.LinearGradient(
	  				                //     0, 0, 0, 1,
	  				                //     [{
	  				                //             offset: 0,
	  				                //             color: '#14c8d4'
	  				                //         },
	  				                //         {
	  				                //             offset: 1,
	  				                //             color: '#43eec6'
	  				                //         }
	  				                //     ]
	  				                // )
	  				                color: function(params) {
	  				                    var colorList = ['#0ec1ff', '#10cdff', '#12daff', '#15ebff', '#17f8ff', '#1cfffb', '#1dfff1'];
	  				                    return colorList[params.dataIndex];
	  				                }
	  				            }
	  				        },
	  				        data: musical
	  				    }]
	  				};
	  	 
	  		yearsChart.setOption(option);
	  		
	  		
	  },"json");
}
 
 function yearSale(data){
	var name=[];
	var datas=[];
	var url="/Listen/statisticalChart/selectYearStatistics.action";
	  $.post(url,data,function(mes){
	  		$.each(mes,function(i,item){
	  			var j={};
	  			j.name=item.name;
	  			j.type="bar";
	  			var arr=new Array();
	  			var arr2=new Array();
	  			arr=item.value.split(",");
	  			for (var i = 0; i < arr.length-1; i++) {
	  				arr2.push(arr[i])
				}
	  			j.data=arr2
	  			name.push(item.name)
	  			datas.push(j)
	  		})
	  	 
	  		var mainChart = echarts.init(document.getElementById('Crash&Dash'));

	  		option = {
	  		    tooltip: {
	  		        trigger: 'axis',
	  		        axisPointer: {
	  		            type: 'cross',
	  		            crossStyle: {
	  		                color: '#999'
	  		            }
	  		        }
	  		    },
	  		    toolbox: {
	  		        feature: {
	  		            dataView: {show: true, readOnly: false},
	  		            magicType: {show: true, type: ['line', 'bar']},
	  		            restore: {show: true},
	  		            saveAsImage: {show: true}
	  		        }
	  		    },
	  		    legend: {
	  		        data:name
	  		    },
	  		    xAxis: [
	  		        {
	  		            type: 'category',
	  		            data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
	  		            axisPointer: {
	  		                type: 'shadow'
	  		            }
	  		        }
	  		    ],
	  		    yAxis: [
	  		        {
	  		            type: 'value',
	  		            name: '销量'
	  		            
	  		        }
	  		         
	  		    ],
	  		    series:datas
	  		};

	  		 mainChart.setOption(option);
	  },"json");
	  
}
 
 
 function sumSale(){
	var url="/Listen/statisticalChart/selectStatistics.action";
	  var data=null;
	  $.post(url,data,function(mes){
	  	$.each(mes,function(i,item){
	  		var j={}
	  		j.value=item.value;
	  		j.name=item.name;
	  		nameMap.push(j)
	  	})
	  	 var mainChart = echarts.init(document.getElementById('type'));

	  	option = {
	  		    
	  		    tooltip : {
	  		        trigger: 'item',
	  		        formatter: "{a} <br/>{b} : {c} ({d}%)"
	  		    },
	  		    legend: {
	  		        x : 'center',
	  		        y : 'bottom',
	  		        data:nameMap
	  		    },
	  		    toolbox: {
	  		        show : true,
	  		        feature : {
	  		            mark : {show: true},
	  		            dataView : {show: true, readOnly: false},
	  		            magicType : {
	  		                show: true,
	  		                type: ['pie', 'funnel']
	  		            },
	  		            restore : {show: true},
	  		            saveAsImage : {show: true}
	  		        }
	  		    },
	  		    calculable : true,
	  		    series : [
	  		        {
	  		            name:'半径模式',
	  		            type:'pie',
	  		            radius : [20, 110],
	  		            center : ['25%', '50%'],
	  		            roseType : 'radius',
	  		            label: {
	  		                normal: {
	  		                    show: false
	  		                },
	  		                emphasis: {
	  		                    show: true
	  		                }
	  		            },
	  		            lableLine: {
	  		                normal: {
	  		                    show: false
	  		                },
	  		                emphasis: {
	  		                    show: true
	  		                }
	  		            },
	  		            data: nameMap
	  		        },
	  		        {
	  		            name:'面积模式',
	  		            type:'pie',
	  		            radius : [30, 110],
	  		            center : ['75%', '50%'],
	  		            roseType : 'area',
	  		            data:nameMap
	  		        }
	  		    ]
	  		};

	    // 使用刚指定的配置项和数据显示图表。
	    mainChart.setOption(option);
	  },"json");
 }
 layui.use('laydate', function(){
		if(companyId=="1"){
			 var laydate = layui.laydate
			  laydate.render({
				  elem: '#startTime'
				  ,type: 'year'
				  ,done: function(value, date){
					  yearSale({"year":value})
				  }
				});
			  
			  laydate.render({
				  elem: '#startTimeTwo'
				  ,type: 'year'
				  ,done: function(value, date){
					  monthsSale({"year":value})
				  }
				});
			
		}else{
			 var laydate = layui.laydate
			  laydate.render({
				  elem: '#startTime'
				  ,type: 'year'
				  ,done: function(value, date){
					  wholesaleOrRetailNumberSumSale({"attribute":"number","year":value});
				  }
				});
			  
			  laydate.render({
				  elem: '#startTimeTwo'
				  ,type: 'year'
				  ,done: function(value, date){
					  wholesaleOrRetailPriceSumSale({"attribute":"price","year":value});
				  }
				});
		}
		 
		
	});

  